﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.Services.Description;


public partial class DataCenterDetail : System.Web.UI.Page
{
    public string time;
    protected List<Model.Lottery> arlist = null;
    protected DataTable Dataallje = null;
    protected DataTable Dataall = null;
    protected DataTable datakaijiang = null;
    protected DataTable Dataallzgje = null;
    protected DataTable Dataallkj = null;
    public string qishu = "";
    public string cptype = "";
    public Int64 jine;
    public Int64 a;
    public Int64 b;
    public Int64 c;
    public string yi;
    public string wan;
    public string yuan;
    protected string css = string.Empty;

    protected void Page_Load(object sender, EventArgs e)
    {

        cptype = Request["t"];
        qishu = Request.Form["tdValue"];
        time = DateTime.Now.ToString("yyyy-MM-dd");

        alljine();
        DataCenterall();

    }

    private void DataCenterall()//彩种
    {
        string sqlstr = "select top(30) * from (select '2' as fangshi , CMember.nickname,LotteryAnnouncement.openTime ,[LotteryChipped].LotteryOpenTime ,[LotteryChipped].WinMoney,[LotteryChipped].MySub  from [LotteryChipped], LotteryAnnouncement,CMember where [LotteryChipped].LotteryOpenTime= [LotteryAnnouncement].LotteryQS  and  LotteryChipped.UserID=CMember.Id and [LotteryChipped].LotteryType=" + cptype + " and IsWin=1 union    all select  '1' as fangshi ,CMember.nickname,LotteryAnnouncement.openTime ,[LotteryBuyDetail].[LotteryQS],[dbo].[LotteryBuyDetail].WinMoney,[LotteryBuyDetail].LotteryMoney from[LotteryBuyDetail], LotteryAnnouncement, CMember  where [LotteryBuyDetail].LotteryQs=[dbo].[LotteryAnnouncement].LotteryQS and [LotteryBuyDetail].User_id=CMember.Id and [LotteryBuyDetail].LotteryType=" + cptype + "  and IsWin=1 )a order by openTime desc";
        Dataall = BLL.LotteryChippedUser.GetPageListBysql(sqlstr);
    }

    private void alljine()//双色球
    {
        string sql = "select LotteryOpenTime,isnull(sum(LotteryChipped.WinMoney),0) as alljine from LotteryChipped  where LotteryType=" + cptype + "  group by LotteryOpenTime order by LotteryOpenTime desc";
        Dataallje = BLL.LotteryChipped.GetPageListBysql(sql);
        string sqll = "select LotteryQs, isnull(sum([LotteryBuyDetail].WinMoney),0) as alljine from [LotteryBuyDetail]  where LotteryType=" + cptype + "group by LotteryQs order by LotteryQs  desc";
        Dataallzgje = BLL.LotteryBuyDetail.GetPageListBysql(sqll);

        if (Dataallje.Rows.Count > 0)
        {
            jine = Convert.ToInt64(Dataallje.Rows[0]["alljine"]) + Convert.ToInt64(Dataallzgje.Rows[0]["alljine"]);
        }
        else
        {
            jine = Convert.ToInt64(Dataallzgje.Rows[0]["alljine"]);
        }

        if (jine > 99999999)
        {
            a = Convert.ToInt64(jine) / 100000000;
            yi = a + "亿";
            jine = jine - a * 100000000;
        }
        if (jine > 9999)
        {
            b = Convert.ToInt64(jine) / 10000;
            wan = b + "万";
            jine = jine - b * 10000;
        }
        if (jine < 10000)
        {

            c = Convert.ToInt64(jine);
            if (c < 1000)
            {
                yuan = "0" + c + "元";
            }
            if (c == 0)
            {
                yuan = null;
            }
            else
            {
                yuan = c + "元";

            }

        }

    }

    protected void qsSelectedIndexChanged(object sender, EventArgs e)
    {

        if (qsDropDownList.SelectedValue == "1")
        {
            Response.Redirect("DataCenterDetail.aspx?t=1");

        }
        if (qsDropDownList.SelectedValue == "2")
        {
            Response.Redirect("DataCenterDetail.aspx?t=2");

        }
        if (qsDropDownList.SelectedValue == "3")
        {
            Response.Redirect("DataCenterDetail.aspx?t=3");

        }
        if (qsDropDownList.SelectedValue == "4")
        {
            Response.Redirect("DataCenterDetail.aspx?t=4");

        }
        if (qsDropDownList.SelectedValue == "5")
        {
            Response.Redirect("DataCenterDetail.aspx?t=5");

        }
        if (qsDropDownList.SelectedValue == "6")
        {
            Response.Redirect("DataCenterDetail.aspx?t=6");

        }
        if (qsDropDownList.SelectedValue == "7")
        {
            Response.Redirect("DataCenterDetail.aspx?t=7");

        }

    }

    private void Lotterynumbers()
    {
        //string sqlkj = "select *  from  [dbo].[LotteryAnnouncement]  where [LotteryQs]="+ 2015154;
        //Dataallkj = BLL.LotteryAnnouncement.GetPageListBysql(sqlkj);
    }


}